//
//  MyMoneyFirstCell.m
//  ShangHaiTuJI
//
//  Created by xiaoxiangtuji on 2017/9/30.
//  Copyright © 2017年 xiaoxiangtuji. All rights reserved.
//

#import "MyMoneyFirstCell.h"

@implementation MyMoneyFirstCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setSubViews];
    }
    return self;
}
-(void)setSubViews{
    UIImageView *bgImageView = [[UIImageView alloc] init];
    bgImageView.userInteractionEnabled = YES;
    bgImageView.image = [UIImage imageNamed:@"jijiMoney"];
    [self.contentView addSubview:bgImageView];
    [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(self.contentView);
        make.height.mas_equalTo(313);
    }];
//    UIImageView *backImaegView = [[UIImageView alloc] init];
//    backImaegView.image = [UIImage imageNamed:@"navigator_btn_back"];
//    backImaegView.userInteractionEnabled = YES;
//    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissTheView:)];
//    [backImaegView addGestureRecognizer:tap];
//    [bgImageView addSubview:backImaegView];
//    [backImaegView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(bgImageView.mas_top).offset(35);
//        make.left.equalTo(bgImageView.mas_left).offset(12);
//        make.size.mas_equalTo(CGSizeMake(16, 16));
//    }];
//    UIButton *ruleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    [ruleBtn setTitle:@"详细规则" forState:UIControlStateNormal];
//    ruleBtn.titleLabel.font = [UIFont systemFontOfSize:12];
//    [ruleBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//    [bgImageView addSubview:ruleBtn];
//    [ruleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(bgImageView.mas_top).offset(35);
//        make.right.equalTo(bgImageView.mas_right).offset(-12);
//        make.size.mas_equalTo(CGSizeMake(60, 16));
//    }];
//    UILabel *titleLabel = [[UILabel alloc] init];
//    titleLabel.textAlignment = NSTextAlignmentCenter;
//    titleLabel.text = @"吉吉金币";
//    titleLabel.font = [UIFont systemFontOfSize:16];
//    titleLabel.textColor = COLOR_HEX(0xFFFFFF);
//    [bgImageView addSubview:titleLabel];
//    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.equalTo(bgImageView.mas_centerX);
//         make.top.equalTo(bgImageView.mas_top).offset(35);
//        make.height.mas_equalTo(16);
//        make.left.equalTo(backImaegView.mas_right).offset(10);
//    }];
    UILabel *recordLabel = [[UILabel alloc] init];
    recordLabel.text = @"2000";
    [bgImageView addSubview:recordLabel];
    recordLabel.textAlignment = NSTextAlignmentCenter;
    recordLabel.font = [UIFont systemFontOfSize:50];
    recordLabel.textColor = [UIColor whiteColor];
    [recordLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(bgImageView.mas_centerX);
        make.top.equalTo(self.contentView.mas_top).offset(45 + 51);
        make.left.equalTo(bgImageView);
        make.height.mas_equalTo(40);
    }];
    UIButton *signBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    signBtn.backgroundColor = COLOR_HEX(0xFFEF80);
    [signBtn setTitle:@" 签到" forState:UIControlStateNormal];
    [signBtn addTarget:self action:@selector(GoSign:) forControlEvents:UIControlEventTouchUpInside];
    [signBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [signBtn setImage:[UIImage imageNamed:@"jijisign"] forState:UIControlStateNormal];
    [bgImageView addSubview:signBtn];
    [signBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(bgImageView.mas_centerX);
        make.height.mas_equalTo(45);
        make.width.mas_equalTo(150);
        make.top.equalTo(recordLabel.mas_bottom).offset(40);
    }];
    signBtn.layer.cornerRadius = 22.5;
    signBtn.layer.masksToBounds = YES;
    UILabel *dayLabel = [[UILabel alloc] init];
    dayLabel.textAlignment = NSTextAlignmentCenter;
    dayLabel.text = @"连续签到1天";
    dayLabel.textColor = [UIColor whiteColor];
    dayLabel.font = [UIFont systemFontOfSize:14];
    [bgImageView addSubview:dayLabel];
    [dayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(signBtn.mas_bottom).offset(20);
        make.left.right.equalTo(bgImageView);
        make.height.mas_equalTo(15);
    }];
    UILabel *bottomLabel = [[UILabel alloc] init];
    bottomLabel.text = @"签到记录";
    bottomLabel.textColor = COLOR_HEX(0x666666);
    bottomLabel.font = [UIFont systemFontOfSize:14];
    bottomLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:bottomLabel];
    [bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.contentView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(scaleLeftAndRight(60), 15));
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-16);
    }];
    UIView *leftLineView = [[UIView alloc] init];
    leftLineView.backgroundColor = COLOR_HEX(0xC9C9C9);
    [self.contentView addSubview:leftLineView];
    [leftLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.equalTo(self.contentView.mas_left).offset(12);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-23);
        make.right.equalTo(bottomLabel.mas_left).offset(-3);
    }];
    UIView *rightLineView = [[UIView alloc] init];
    rightLineView.backgroundColor = COLOR_HEX(0xC9C9C9);
    [self.contentView addSubview:rightLineView];
    [rightLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.right.equalTo(self.contentView.mas_right).offset(-12);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-23);
        make.left.equalTo(bottomLabel.mas_right).offset(3);
    }];
    UIImageView *headerImageView = [[UIImageView alloc] init];
     [headerImageView sd_setImageWithURL:[NSURL URLWithString:[[NSUserDefaults standardUserDefaults] objectForKey:@"HEADERICON"]] placeholderImage:[UIImage imageNamed:@"DefaultICon"]];
    [self.contentView addSubview:headerImageView];
    [headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self.contentView.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(80, 80));
        make.bottom.equalTo(bottomLabel.mas_top).offset(-22);
    }];
    headerImageView.layer.cornerRadius = 40;
    headerImageView.layer.masksToBounds = YES;
}
-(void)GoSign:(UIButton *)btn{
    self.gosignBlock();
    btn.userInteractionEnabled = NO;
    btn.backgroundColor = COLOR_HEX(0xadadad);
}
-(void)dismissTheView:(UITapGestureRecognizer *)tap{
    if (self.closeViewBlock) {
        self.closeViewBlock();
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
